package com.study.thread;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class SyncMethodClass {

    private static final Logger logger = LoggerFactory.getLogger(SyncMethodClass.class);

    /**
     * @description 修饰普通方法（锁住的是当前实例对象）
     * @author hw
     * @date 2021/12/29 23:09:33
     */
    public synchronized void test1(){
        logger.info(Thread.currentThread().getName() + "test1 进入了同步方法");
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        logger.info(Thread.currentThread().getName() + "test1 结束");
    }
}
